from django.contrib import admin

# Register your models here.
from job.models import FilesPath, AppConfig, MenuInfo
from job.models import JobConfig
from job.models import GroupInfo

class DjangoConfigAdmin(admin.ModelAdmin):
    # 指定后台网页要显示的字段
    list_display = ["id", "app_range", "act_type", "key_name", "key_value", "description"]
    # 右侧栏过滤器
    list_filter = ['app_range', 'act_type']
    # 要搜索的列的值
    search_fields = ['key_name']

class MenuInfoAdmin(admin.ModelAdmin):
    # 指定后台网页要显示的字段
    list_display = ["id", "title_flag", "list_flag", "menu_name", "url_name"]
    list_per_page = 12
    ordering = ['id']

class FilesPathAdmin(admin.ModelAdmin):
    # 指定后台网页要显示的字段
    list_display = ["id", "doc_type", "upload_file", "cn_name"]
    list_per_page = 12
    ordering = ['id']

class JobConfigAdmin(admin.ModelAdmin):
    # 指定后台网页要显示的字段
    list_display = ["id", "job_name", "job_id", "flag", "funName", "corn_day", "corn_hour", "corn_min", "skip_date", "param"]
    # 右侧栏过滤器
    list_filter = ['funName']
    # 要搜索的列的值
    search_fields = ['job_id']
    # 修改时显示行数
    fields = (('job_name', 'flag'), ('job_id', 'funName'), ('corn_day', 'corn_hour', 'corn_min', 'skip_date'), 'group_id', 'param')
    filter_horizontal = ('group_id',)
    list_per_page = 5
    ordering = ['id']

class GroupInfoAdmin(admin.ModelAdmin):
    # 指定后台网页要显示的字段
    list_display = ["id", "group_id", "cn_name", "user", "phone", "email"]
    # 右侧栏过滤器
    list_filter = ['group_id']
    # 要搜索的列的值
    search_fields = ['cn_name']
    list_per_page = 10
    ordering = ['id']

# 注册到admin
admin.site.register(AppConfig, DjangoConfigAdmin)
admin.site.register(MenuInfo, MenuInfoAdmin)
admin.site.register(FilesPath, FilesPathAdmin)
admin.site.register(JobConfig, JobConfigAdmin)
admin.site.register(GroupInfo, GroupInfoAdmin)